#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

typedef long long ll;

const int N = 5e3 + 5, mod = 998244353;
int n, k, a[N], f[N][N], pw[N], siz[N];
int e_cnt, heads[N];
std::vector<int> G[N];

struct Edge {
  int v, nxt;
} e[N << 1];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

inline int qpow(ll x, int k) {
  ll res = 1;
  while (k) {
    if (k & 1) res = res * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return res;
}

void dfs(int u, int fa) {
  siz[u] = 1;
  for (size_t i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    for (int j = 0; j <= k; j++) f[v][j] = f[u][j];
    dfs(v, u);
    siz[u] += siz[v];
    for (int j = k; ~j; j--)
      f[u][j] = ((ll)f[u][j] * pw[siz[v] - 1] % mod + f[v][j]) % mod;
  }
  for (int i = k; ~i; i--) f[u][i] = i >= a[u] ? f[u][i - a[u]] : 0;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("luge.in", "r", stdin);
  freopen("luge.out", "w", stdout);
#endif
#endif

  read(n), read(k);
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 1, x, y; i < n; i++) {
    read(x), read(y);
    G[x].push_back(y), G[y].push_back(x);
  }
  f[1][0] = 1;
  pw[0] = 1;
  for (int i = 1; i <= n; i++) pw[i] = ((ll)pw[i - 1] << 1) % mod;
  dfs(1, 1);
  printf("%lld\n", (ll)f[1][k] * qpow(pw[n - 1], mod - 2) % mod);
  return 0;
}